﻿/******************************************************************************
 *      Class:      DateStringConverter
 *      Authors:    Michael Slezak, Samuel Harrington
 *      Implements: IValueConverter
 *      
 * ----------------------------------------------------------------------------
 * 
 *      Description:
 *          Given a DateTime structure, formats it into a more human readable
 *          string. Also converts(parses) a string into a DateTime structure.
 *          
 ******************************************************************************/
////////////////////////////////////////////////////////////////////////////////
//   INCLUDES
////////////////////////////////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;

namespace WeatherStationProgram
{
    public class DateStringConverter : IValueConverter
    {
        /***********************************************************************
          *      Function: Convert
          *      Authors:  Michael Slezak, Samuel Harrington
          *      Parameters:
          *          object value - the object to convert
          *          Type targetType - the type to convert to
          *          object parameter - not sure what this is and is not relevant to the function
          *          CultureInfo culture - same as parameter. Irrelevant to the function
          *      Returns:  object
          *      Purpose:  Converts a DateTime to a string.
          * *********************************************************************/
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            DateTime date = (DateTime)value;
            return date.ToShortDateString() + " " + date.ToLongTimeString();
        }

        /***********************************************************************
          *      Function: ConvertBack
          *      Authors:  Michael Slezak, Samuel Harrington
          *      Parameters:
          *          object value - the object to convert
          *          Type targetType - the type to convert to
          *          object parameter - not sure what this is and is not relevant to the function
          *          CultureInfo culture - same as parameter. Irrelevant to the function
          *      Returns:  object
          *      Purpose:  Converts a string to a DateTime structure.
          * *********************************************************************/
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return DateTime.Parse(value.ToString());
        }
    }
}
